export const _process = {
	//数据是对象
	dataObject(res) {
		if (res.success + "" === "true") {
			return {
				...(res.result || {}),
				code: 200
			};
		}
		return {};
	},
	//数据是字符串
	dataString(res) {
		if (res.success + "" === "true") {
			return {
				...res,
				code: 200
			};
		}
		return {};
	},
	//数据是数组
	dataArray(res) {
		const obj = {
			data: [],
			total: 0
		};
		if (res.success + "" === "true") {
			const data = res.result || [];
			return {
				data,
				code: 200,
				total: data.length
			}
		}
		return obj;
	},
	//分页数组
	dataPageArray(res) {
		res = _process.dataArray(res);
		return {
			...res,
			...(res.data || {}),
			data: (res.data || {}).records || []
		}
	}
}
import {
	isDD,
	isWX,
	debounce
} from "./api.js";
import {
	httpUp,
	httpGet,
} from './fetch.js';

export const login = debounce(e => {
	//登录方式处理
	if (isDD) {
		return ddLogin().then(_process.dataObject);
	} else if (isWX) {
		
	}
}, 3000, true);

//上传
export const uploadFile = (...e) => {
	return httpUp(null,...e);
}

//上传 发票
export const uploadImg = (...e) => {
	return httpUp('/expense/expenseInvoice/api/add',...e);
}

//y-picker - 通过区域ID查询下级
export const queryPositionByParentId = (data) => {
	return httpGet('/web/api/queryPositionByParentId', {
		pid: 0,
		...data
	}).then(_process.dataArray);
}
